<?php
class IndexController extends Zend_Controller_Action
{
    public function init()
    {
        
    }
    public function indexAction()
    {
        
        
        
    }
    /**
     * menuAction
     * Menu rendering
     * 
     * @param   Int id
     * @return  void
     */
    public function menuAction()
    {
        $this->getHelper('layout')->disableLayout(true);
        if ($this->_hasParam('id')) {
            $id = (int) $this->_getParam('id');
            $db = Tv_Arte_Reg::getDb();    
            $dp = $db->select()->from('menus', '*, CONCAT(\'' . ROOT_HTTP . '/public\', href) as href')
                ->order('order ASC')->query()->fetchAll();
           
            $tmp = Array();
            foreach ($dp as &$value) {
                array_push($tmp, new Tv_Arte_Nav_Std_Data($value));
            } unset($value);
            $dp = $tmp;
            
            
            
            
            
            $builder = new Tv_Arte_Nav_Builder($dp, Array('parentId' => $id));
            
            
            
            
            /*$builder = Tv_Arte_Tree_Std_Builder::create($dp, $id);
            
            
            
            
            if (0 === count($builder->getTree()->getChildren())) {
                throw new Zend_Controller_Action_Exception('Le menu ne contient aucun element');
            }
            $this->view->assign('menu', Tv_Arte_Tree_ABuilder::helper($builder, new Tv_Arte_Tree_Std_Renderer()));*/
        } else {
            throw new Zend_Controller_Action_Exception('Le parametre id est obligatoire');
        }
    }
    
    
}